from datetime import datetime, timedelta, timezone

import pytz
from django.contrib.auth.models import User, Group
from django.db import models
from django.utils.timezone import now

User._meta.verbose_name = '用户'
User._meta.verbose_name_plural = '用户'

Group._meta.verbose_name = '用户组'
Group._meta.verbose_name_plural = '用户组'


# Create your models here.
class ExtendedUser(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE, verbose_name='用户')
    phone_number = models.CharField(max_length=16, null=True, verbose_name='手机号码')
    open_id = models.CharField(max_length=32, null=True, blank=True, verbose_name='小程序唯一标识')
    union_id = models.CharField(max_length=32, null=True, blank=True, verbose_name='微信绑定')
    avatar = models.CharField(max_length=128, null=True, blank=True, verbose_name='头像')
    email_notifications_enabled = models.BooleanField(default=False, verbose_name="是否接收邮箱订阅")
    language = models.IntegerField(default=1, verbose_name="语言(简体=1，繁体=2)")
    vip_expired_time = models.DateTimeField(verbose_name="会员过期时间")
    is_first_payment = models.BooleanField(default=True, verbose_name='是不是首次支付')
    credit_score = models.IntegerField(default=30, verbose_name="信用分")

    class Meta:
        db_table = 'extended_user'
        verbose_name = "用户扩展"  # 设置模型在Django Admin中显示的名称
        verbose_name_plural = "用户扩展"  # 设置模型的复数


class TokenBlacklist(models.Model):
    token = models.CharField(max_length=256, verbose_name='token黑名单')

    class Meta:
        db_table = 'token_blacklist'
        verbose_name = '黑名单'
        verbose_name_plural = '黑名单'
